﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using System.Diagnostics;
using Net.Chirash.Twitter.TwitterClient;
using Net.Chirash.Twitter.TwitterClient.DBSyncronize;
using Net.Chirash.Twitter.TwitterDatabase;

namespace Net.Chirash.Twitter.TweetZone
{
    /// <summary>
    /// App.xaml の相互作用ロジック
    /// </summary>
    public partial class App : Application
    {
        #region Public Properteis

        private const string ConsumerKey = "8UwTJZJMJjl4uLZduYvA";
        private const string ConsumerSecret = "eCnmRK0mDSXfjm95j947iixyDaUY3OZleSdkWMhLc";
        public TwitterConnection Connection { get; private set; }
        public CachingTimerSynchronizer TimerSynchronizer { get { return this.Resources["TimerSynchronizer"] as CachingTimerSynchronizer; } }
        public CachingObservingSynchronizer ObservingSynchronizer { get { return this.Resources["ObservingSynchronizer"] as CachingObservingSynchronizer; } }
        public static App CurrentApp { get { return (App)App.Current; } }
        public User User { get; set; }

        #endregion

        #region Private Methods

        /// <summary>
        /// Initialize token when we are debugging
        /// </summary>
        [System.Diagnostics.Conditional("DEBUG")]
        private void InitializeToken()
        {
            Connection.Token = "141500207-0sEjrUZwRXujtATsDh4gFSAX3qhCVycqJBtDiWuq";
            Connection.TokenSecret = "jZZKmbXhJzh933Eg84P7bEIjNBbp3uNM3q52i8CwU";
        }

        #endregion

        #region Private Events

        private void Application_Startup(object sender, StartupEventArgs e)
        {
            Connection = new TwitterConnection()
            {
                ConsumerKey = ConsumerKey,
                ConsumerSecret = ConsumerSecret
            };
            InitializeToken();

            //TraceListener listener = new TextWriterTraceListener(Console.Out);
            //Trace.Listeners.Add(listener);
        }

        #endregion
    }
}
